package com.game;

import java.util.Scanner;
import java.util.Timer;
import java.util.TimerTask;

public class WordGame extends Thread{

    public static void main(String[] args) {
        paly(true);
    }

    public static void paly(boolean flag){
        int score = 0;
        Scanner scanner = new Scanner(System.in);
        while (flag){
            //int letter ='a'+(int)(Math.random()*26);
            String letter = ""+(char)(Math.random()*26+'a');
            System.out.println(letter);
            long startTime=System.currentTimeMillis();
            String word= scanner.next();
            long endTime=System.currentTimeMillis(); //获取结束时间
            if(letter.equals(word)){
                score++;
                System.out.println("您的分数"+ score);
                System.out.println("*******所用时间为" + (endTime - startTime) /1000 + "秒");
            }else {
                System.out.println("**********对不起你输入错误，游戏结束！！！！********");
                System.out.println("你的最终分数为："+score);
                flag = false;
            }
        }


    }



}
